package org.unigram.oluolu.recommend;

import java.io.IOException;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.Reducer.Context;

/**
 *
 */
public class ExtractRelatedUsersReducer extends
        Reducer<LongWritable, LongWritable, LongWritable, LongWritable> {

    /**
     * reduce method.
     * 
     * @param targetId target user id
     * @param candidates related user id with target
     * @param context context
     * 
     * @throws IOException -
     * @throws InterruptedException -
     */
    @Override
    public final void reduce(final LongWritable targetId,
            final Iterable<LongWritable> candidates, final Context context)
            throws IOException, InterruptedException {
        for (LongWritable cid : candidates) {
            context.write(targetId, cid);
        }
    }
}
